﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace SubstringExtractor
{
    class SubstringExtractor
    {
        public static List<string> ExtractBySubstring(string substring, string text)
        {
            string pattern = @"\b\w*" + substring + @"\w*\b";
            Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
            MatchCollection matches = regex.Matches(text);
            List<string> items = new List<string>();
            foreach (Match match in matches)
            {
                items.Add(match.Value);
            }
            return items;
        }

        static void Main()
        {
            string target = "test";
            string text = "Testing is important. We need to test everything.";
            List<string> matches = ExtractBySubstring(target, text);
            foreach (string match in matches)
            {
                Console.WriteLine(match);
            }
        }
    }
}
